package com.example.controller;


import com.example.common.result.Result;
import com.example.entity.dto.ScraporderAddDto;
import com.example.entity.dto.ScraporderSelectDto;
import com.example.entity.dto.ScraporderUpdateDto;
import com.example.entity.vo.CommonPageVo;
import com.example.entity.vo.ScraporderVo;
import com.example.service.ScraporderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lan
 * @since 2025-01-08
 */
@RestController
@RequestMapping("/api/scraporder")
@Api(tags = "报废单模块")
public class ScraporderController {

    @Autowired
    private ScraporderService service;

    @PostMapping("/list")
    @ApiOperation("查询所有报废单")
    public Result<CommonPageVo<ScraporderVo>> list(@RequestBody ScraporderSelectDto dto) {
        return Result.success(service.allList(dto));
    }

    @PostMapping("/add")
    @ApiOperation("新增报废单")
    public Result<?> addScraporder(@RequestBody ScraporderAddDto dto) {
        service.addScraporder(dto);
        return Result.success();
    }

    @PostMapping("/update")
    @ApiOperation("修改报废单")
    public Result<?> updateScraporder(@RequestBody ScraporderUpdateDto dto) {
        service.updateScraporder(dto);
        return Result.success();
    }

    @GetMapping("/delete")
    @ApiOperation("删除报废单")
    public Result<?> deleteScraporder(@RequestParam String orderNumber) {
        service.deleteScraporder(orderNumber);
        return Result.success();
    }
}
